import {defineConfig, loadEnv} from "vite";
import vue from "@vitejs/plugin-vue";
const path = require('path')
import vueJsx from "@vitejs/plugin-vue-jsx";
function resolve(dir) {
    return path.join(__dirname, dir)
}
// https://vitejs.dev/config/
export default defineConfig((mode)=>{
    return {
        plugins: [vue(),vueJsx()],
        server: {
            host: "0.0.0.0",
            proxy: {
                "/api": {
                    // target: "http://localhost:3000",
                    target:  loadEnv(mode, process.cwd()).VITE_SEARVER_HOST,
                    changeOrigin: true,
                    rewrite: (path) => path.replace(/^\/api/, '')
                },
                "/test": {
                    target: "http://tengyuxin-bucket.oss-cn-beijing.aliyuncs.com",
                    ws: true,
                    changeOrigin: true,
                    rewrite: (path) => path.replace(/^\/test/, '')
                }
            },
        },
        resolve:{
            //设置路径别名
            alias: {
                '@': path.resolve(__dirname, './src'),
                '*': path.resolve('')
            },
        }
    }
});
